package com.yuheadline.model.article.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * 类型。0：内容；1：封面
 *
 * @author 高翔宇
 * @since 2025/4/24 周四 07:53
 */
@Getter
public enum ImageTypeEnum {
    CONTENT(0, "内容"),
    COVER(1, "封面");
    @EnumValue
    private final Integer code;
    @JsonValue
    private final String description;

    ImageTypeEnum(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 通过状态码获取枚举
     */
    public static ImageTypeEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (ImageTypeEnum type : ImageTypeEnum.values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return null;
    }
}